﻿CREATE PROCEDURE [dbo].[ReportPTODetail]
@startDate DATETIME, @endDate DATETIME
AS
BEGIN
	SELECT EntryLog.EntryDate, EntryLog.Duration, Categories.Name AS Category, EntryLog.Description, Users.FullName AS Name
	FROM  EntryLog INNER JOIN
				   Users ON EntryLog.UserID = Users.UserID INNER JOIN
				   UserType ON Users.UserTypeID = UserType.UserTypeID INNER JOIN
				   Projects ON EntryLog.ProjectID = Projects.ProjectID INNER JOIN
				   ProjectCategories ON EntryLog.CategoryID = ProjectCategories.CategoryID AND ProjectCategories.ProjectID = Projects.ProjectID INNER JOIN
				   Categories ON ProjectCategories.CategoryID = Categories.CategoryID
	WHERE (EntryLog.ProjectID = 21) AND (UserType.UserTypeID = 1) AND (EntryLog.EntryDate >= @startDate) AND (EntryLog.EntryDate <= @endDate)
	ORDER BY Users.FullName, Category
END

